using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VBSSATZ
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "TST":
                case "UBT":
                default:
                    #region=========
                    dwReturn["BSMANDANT"] = app.Mandant;
                    dwReturn["BSKART"] = "                    ";
                    dwReturn["BSAENDZL"] = "0";
                    dwReturn["BSAENDBEN"] = "        ";
                    dwReturn["BSAENDDAT"] = "0";
                    dwReturn["BSNEUBEN"] = "        ";
                    dwReturn["BSNEUDAT"] = "0";
                    dwReturn["BSMTART"] = "    ";
                    dwReturn["BSBEZ"] = "                                        ";
                    dwReturn["BSSTDKVAR"] = "1 ";
                    dwReturn["BSSTAKZ"] = "A";
                    dwReturn["BSMUSTER"] = "N";
                    dwReturn["BSFARBVW"] = "J";
                    dwReturn["BSFARBSTUE"] = "J";
                    dwReturn["BSPFVARN"] = " ";
                    dwReturn["BSPROGRP"] = "   ";
                    dwReturn["BSARTGRP"] = "   ";
                    dwReturn["BSPMGRP"] = "    ";
                    dwReturn["BSBAUMKZ"] = "Z";
                    dwReturn["BSVERWEN"] = "2";
                    dwReturn["BSFDZ"] = "0";
                    dwReturn["BSFDZLEIST"] = "0";
                    dwReturn["BSKNOTEN"] = "J";
                    dwReturn["BSFAKTOR"] = "100";
                    dwReturn["BSSRFNR"] = "               ";
                    dwReturn["BSCADKEY"] = "                              ";
                    dwReturn["BSANZTB"] = "00";
                    dwReturn["BSKRANF"] = "          ";
                    dwReturn["BSKRENDE"] = "          ";
                    dwReturn["BSKRMITTE"] = " ";
                    dwReturn["BSFDFLGKR"] = "           ";
                    dwReturn["BSKRART"] = "          ";
                    dwReturn["BSSCHAERBR"] = "0";
                    dwReturn["BSRIETF"] = "0";
                    dwReturn["BSFDFLGRI"] = "           ";
                    dwReturn["BSBEM"] = "                                        ";
                    dwReturn["BSZOLLTNR"] = "                    ";
                    dwReturn["BSSUBSTGR"] = "   ";
                    dwReturn["BSHANDICAP"] = "   ";
                    dwReturn["BSAFFINITY"] = "               ";
                    dwReturn["BSSUBST1"] = "  ";
                    dwReturn["BSSUBST2"] = "  ";
                    dwReturn["BSBLEACHED"] = " ";
                    dwReturn["BSCLORINEST"] = " ";
                    dwReturn["BSFIXTEMP"] = "0";
                    dwReturn["BSPRODH"] = "                  ";
                    dwReturn["BSMATKL"] = "         ";
                    dwReturn["BSPLGRP"] = "  ";
                    dwReturn["BSPLANART"] = "                    ";
                    dwReturn["BSEKGRP"] = "   ";
                    dwReturn["BSBSTME"] = "   ";
                    dwReturn["BSVABME"] = " ";
                    dwReturn["BSEKWSL"] = "    ";
                    dwReturn["BSINKZ"] = " ";
                    dwReturn["BSINPR"] = "0";
                    dwReturn["BSBEWAB"] = "0";
                    dwReturn["BSFILLER"] = "0                                                               ";
                    #endregion
                    break;
                case "JLT":

                    break;
            }
        }
        public void MapBSSATZ(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void SaveBSSATZ(DataRow dwData, DataRow dwDispo)
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryBSSATZ(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }

            MapBSSATZ(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertBSSATZ(dwLocal);
            }
            UpdateBSSATZ(dwLocal);
        }
        public void InsertBSSATZ(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {
                case "JLT":
                    or1.CommandText = "INSERT INTO BSSATZ(BSMANDANT, BSKART, BSAENDZL, BSAENDBEN, BSAENDDAT, BSNEUBEN, BSNEUDAT, BSMTART, BSBEZ, BSSTDKVAR, BSSTAKZ, BSMUSTER, BSFARBVW, BSFARBSTUE, BSPFVARN, BSPROGRP, BSARTGRP, BSPMGRP, BSBAUMKZ, BSVERWEN, BSFDZ, BSFDZLEIST, BSKNOTEN, BSFAKTOR, BSSRFNR, BSCADKEY, BSANZTB, BSKRANF, BSKRENDE, BSKRMITTE, BSFDFLGKR, BSKRART, BSSCHAERBR, BSRIETF, BSFDFLGRI, BSBEM, BSZOLLTNR, BSSUBSTGR, BSHANDICAP, BSAFFINITY, BSSUBST1, BSSUBST2, BSBLEACHED, BSCLORINEST, BSFIXTEMP, BSPRODH, BSMATKL, BSPLGRP, BSPLANART, BSEKGRP, BSBSTME, BSVABME, BSEKWSL, BSINKZ, BSINPR, BSBEWAB, BSFILLER)"
                    + "VALUES (:BSMANDANT, :BSKART, 0, '        ', 0, :BSNEUBEN, :BSNEUDAT, '    ', '                                        ', '1 ', 'A', 'N', 'J', 'J', ' ', '   ', '   ', '    ', :BSBAUMKZ,:BSVERWEN, 0, 0, 'J', 1000, '               ', '                              ', '00', '          ', '          ', ' ', '           ', '          ', 0, 0, '           ', '                                        ', '                    ', '   ', '   ', '               ', '  ', '  ', ' ', ' ', 0, '                  ', '         ', '  ', '                    ', '   ', '   ', ' ', '    ', ' ', 0, 0, '                                                                ')";
                    or1.Parameters.Add("BSMANDANT", OracleType.NVarChar).Value = dwData["BSMANDANT"].ToString();
                    or1.Parameters.Add("BSKART", OracleType.NVarChar).Value = dwData["BSKART"].ToString();
                    or1.Parameters.Add("BSNEUBEN", OracleType.NVarChar).Value = dwData["BSNEUBEN"].ToString();
                    or1.Parameters.Add("BSNEUDAT", OracleType.Number).Value = dwData["BSNEUDAT"].ToString();
                    or1.Parameters.Add("BSBAUMKZ", OracleType.NVarChar).Value = dwData["BSBAUMKZ"].ToString();
                    or1.Parameters.Add("BSVERWEN", OracleType.NVarChar).Value = dwData["BSVERWEN"].ToString();
                    break;
                case "YGR":
                case "TST":
                case "UBT":
                default:
                    or1.CommandText = "INSERT INTO BSSATZ ( BSMANDANT,BSKART,BSAENDZL,BSAENDBEN,BSAENDDAT,BSNEUBEN,BSNEUDAT,BSMTART,BSBEZ,BSSTDKVAR,BSSTAKZ,BSMUSTER,BSFARBVW,BSFARBSTUE,BSPFVARN,BSPROGRP,BSARTGRP,BSPMGRP,BSBAUMKZ,BSVERWEN,BSFDZ,BSFDZLEIST,BSKNOTEN,BSFAKTOR,BSSRFNR,BSCADKEY,BSANZTB,BSKRANF,BSKRENDE,BSKRMITTE,BSFDFLGKR,BSKRART,BSSCHAERBR,BSRIETF,BSFDFLGRI,BSBEM,BSZOLLTNR,BSSUBSTGR,BSHANDICAP,BSAFFINITY,BSSUBST1,BSSUBST2,BSBLEACHED,BSCLORINEST,BSFIXTEMP,BSPRODH,BSMATKL,BSPLGRP,BSPLANART,BSEKGRP,BSBSTME,BSVABME,BSEKWSL,BSINKZ,BSINPR,BSBEWAB,BSFILLER)"
                    + " VALUES (:BSMANDANT:,:BSKART:,:BSAENDZL:,:BSAENDBEN:,:BSAENDDAT:,:BSNEUBEN:,:BSNEUDAT:,:BSMTART:,:BSBEZ:,:BSSTDKVAR:,:BSSTAKZ:,:BSMUSTER:,:BSFARBVW:,:BSFARBSTUE:,:BSPFVARN:,:BSPROGRP:,:BSARTGRP:,:BSPMGRP:,:BSBAUMKZ:,:BSVERWEN:,:BSFDZ:,:BSFDZLEIST:,:BSKNOTEN:,:BSFAKTOR:,:BSSRFNR:,:BSCADKEY:,:BSANZTB:,:BSKRANF:,:BSKRENDE:,:BSKRMITTE:,:BSFDFLGKR:,:BSKRART:,:BSSCHAERBR:,:BSRIETF:,:BSFDFLGRI:,:BSBEM:,:BSZOLLTNR:,:BSSUBSTGR:,:BSHANDICAP:,:BSAFFINITY:,:BSSUBST1:,:BSSUBST2:,:BSBLEACHED:,:BSCLORINEST:,:BSFIXTEMP:,:BSPRODH:,:BSMATKL:,:BSPLGRP:,:BSPLANART:,:BSEKGRP:,:BSBSTME:,:BSVABME:,:BSEKWSL:,:BSINKZ:,:BSINPR:,:BSBEWAB:,:BSFILLER:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
                    break;

            }

            Connect2Proxy(or1);
        }
        public override string BATCHINSERT(DataRow dwData)
        {
            dwData["BSNEUBEN"] = app.User;
            dwData["BSNEUDAT"] = date;
            string value = "";
            switch (app.company)
            {
                default:
                case "SXN":
                case "YGR":
                case "TST":
                    value = "INTO BSSATZ  "
                    + " VALUES (:BSMANDANT:,:BSKART:,:BSAENDZL:,:BSAENDBEN:,:BSAENDDAT:,:BSNEUBEN:,:BSNEUDAT:,:BSMTART:,:BSBEZ:,:BSSTDKVAR:,:BSSTAKZ:,:BSMUSTER:,:BSFARBVW:,:BSFARBSTUE:,:BSPFVARN:,:BSPROGRP:,:BSARTGRP:,:BSPMGRP:,:BSBAUMKZ:,:BSVERWEN:,:BSFDZ:,:BSFDZLEIST:,:BSKNOTEN:,:BSFAKTOR:,:BSSRFNR:,:BSCADKEY:,:BSANZTB:,:BSKRANF:,:BSKRENDE:,:BSKRMITTE:,:BSFDFLGKR:,:BSKRART:,:BSSCHAERBR:,:BSRIETF:,:BSFDFLGRI:,:BSBEM:,:BSZOLLTNR:,:BSSUBSTGR:,:BSHANDICAP:,:BSAFFINITY:,:BSSUBST1:,:BSSUBST2:,:BSBLEACHED:,:BSCLORINEST:,:BSFIXTEMP:,:BSPRODH:,:BSMATKL:,:BSPLGRP:,:BSPLANART:,:BSEKGRP:,:BSBSTME:,:BSVABME:,:BSEKWSL:,:BSINKZ:,:BSINPR:,:BSBEWAB:,:BSFILLER:)";
                    value = INTEXDBC.InjectData(value, dwData);
                    break;
            }
            return value;
        }
        public void DeleteBSSATZ(string client, string art)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE  BSSATZ"
           + " WHERE  BSMANDANT=:BSMANDANT AND BSKART=:BSKART";
            or1.Parameters.Add("BSMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("BSKART", OracleType.NVarChar).Value = art;
            Connect2Proxy(or1);
        }
        public void DBSSATZ01(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE  BSSATZ"
            + " WHERE  BSMANDANT=:BSMANDANT: AND BSKART=:BSKART:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UpdateBSSATZ(DataRow dwData, int option=1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    case "JLT":
                        UBS01(dwData);
                        break;
                    case "YGR":
                    case "TST":
                    case "UBT":
                    default:
                        UBS02(dwData);
                        break;
                }
            }

        }

        public void UBS01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BSSATZ SET "
                + "BSMANDANT=:BSMANDANT,"
                + "BSKART=:BSKART,"
                + "BSAENDZL=:BSAENDZL,"
                + "BSAENDBEN=:BSAENDBEN,"
                + "BSAENDDAT=:BSAENDDAT,"
                + "BSNEUBEN=:BSNEUBEN,"
                + "BSNEUDAT=:BSNEUDAT,"
                + "BSMTART=:BSMTART,"
                + "BSBEZ=:BSBEZ,"
                + "BSSTDKVAR=:BSSTDKVAR,"
                + "BSSTAKZ=:BSSTAKZ,"
                + "BSMUSTER=:BSMUSTER,"
                + "BSFARBVW=:BSFARBVW,"
                + "BSFARBSTUE=:BSFARBSTUE,"
                + "BSPFVARN=:BSPFVARN,"
                + "BSPROGRP=:BSPROGRP,"
                + "BSARTGRP=:BSARTGRP,"
                + "BSPMGRP=:BSPMGRP,"
                + "BSBAUMKZ=:BSBAUMKZ,"
                + "BSVERWEN=:BSVERWEN,"
                + "BSFDZ=:BSFDZ,"
                + "BSFDZLEIST=:BSFDZLEIST,"
                + "BSKNOTEN=:BSKNOTEN,"
                + "BSFAKTOR=:BSFAKTOR,"
                + "BSSRFNR=:BSSRFNR,"
                + "BSCADKEY=:BSCADKEY,"
                + "BSANZTB=:BSANZTB,"
                + "BSKRANF=:BSKRANF,"
                + "BSKRENDE=:BSKRENDE,"
                + "BSKRMITTE=:BSKRMITTE,"
                + "BSFDFLGKR=:BSFDFLGKR,"
                + "BSKRART=:BSKRART,"
                + "BSSCHAERBR=:BSSCHAERBR,"
                + "BSRIETF=:BSRIETF,"
                + "BSFDFLGRI=:BSFDFLGRI,"
                + "BSBEM=:BSBEM,"
                + "BSZOLLTNR=:BSZOLLTNR,"
                + "BSSUBSTGR=:BSSUBSTGR,"
                + "BSHANDICAP=:BSHANDICAP,"
                + "BSAFFINITY=:BSAFFINITY,"
                + "BSSUBST1=:BSSUBST1,"
                + "BSSUBST2=:BSSUBST2,"
                + "BSBLEACHED=:BSBLEACHED,"
                + "BSCLORINEST=:BSCLORINEST,"
                + "BSFIXTEMP=:BSFIXTEMP,"
                + "BSPRODH=:BSPRODH,"
                + "BSMATKL=:BSMATKL,"
                + "BSPLGRP=:BSPLGRP,"
                + "BSPLANART=:BSPLANART,"
                + "BSEKGRP=:BSEKGRP,"
                + "BSBSTME=:BSBSTME,"
                + "BSVABME=:BSVABME,"
                + "BSEKWSL=:BSEKWSL,"
                + "BSINKZ=:BSINKZ,"
                + "BSINPR=:BSINPR,"
                + "BSBEWAB=:BSBEWAB,"
                + "BSFILLER=:BSFILLER "
                + " WHERE  BSMANDANT=:BSMANDANT AND BSKART=:BSKART";

            or1.Parameters.Add("BSMANDANT", OracleType.NVarChar).Value = dwData["BSMANDANT"].ToString();
            or1.Parameters.Add("BSKART", OracleType.NVarChar).Value = dwData["BSKART"].ToString();
            or1.Parameters.Add("BSAENDZL", OracleType.NVarChar).Value = dwData["BSAENDZL"].ToString();
            or1.Parameters.Add("BSAENDBEN", OracleType.NVarChar).Value = dwData["BSAENDBEN"].ToString();
            or1.Parameters.Add("BSAENDDAT", OracleType.NVarChar).Value = dwData["BSAENDDAT"].ToString();
            or1.Parameters.Add("BSNEUBEN", OracleType.NVarChar).Value = dwData["BSNEUBEN"].ToString();
            or1.Parameters.Add("BSNEUDAT", OracleType.NVarChar).Value = dwData["BSNEUDAT"].ToString();
            or1.Parameters.Add("BSMTART", OracleType.NVarChar).Value = dwData["BSMTART"].ToString();
            or1.Parameters.Add("BSBEZ", OracleType.NVarChar).Value = dwData["BSBEZ"].ToString();
            or1.Parameters.Add("BSSTDKVAR", OracleType.NVarChar).Value = dwData["BSSTDKVAR"].ToString();
            or1.Parameters.Add("BSSTAKZ", OracleType.NVarChar).Value = dwData["BSSTAKZ"].ToString();
            or1.Parameters.Add("BSMUSTER", OracleType.NVarChar).Value = dwData["BSMUSTER"].ToString();
            or1.Parameters.Add("BSFARBVW", OracleType.NVarChar).Value = dwData["BSFARBVW"].ToString();
            or1.Parameters.Add("BSFARBSTUE", OracleType.NVarChar).Value = dwData["BSFARBSTUE"].ToString();
            or1.Parameters.Add("BSPFVARN", OracleType.NVarChar).Value = dwData["BSPFVARN"].ToString();
            or1.Parameters.Add("BSPROGRP", OracleType.NVarChar).Value = dwData["BSPROGRP"].ToString();
            or1.Parameters.Add("BSARTGRP", OracleType.NVarChar).Value = dwData["BSARTGRP"].ToString();
            or1.Parameters.Add("BSPMGRP", OracleType.NVarChar).Value = dwData["BSPMGRP"].ToString();
            or1.Parameters.Add("BSBAUMKZ", OracleType.NVarChar).Value = dwData["BSBAUMKZ"].ToString();
            or1.Parameters.Add("BSVERWEN", OracleType.NVarChar).Value = dwData["BSVERWEN"].ToString();
            or1.Parameters.Add("BSFDZ", OracleType.NVarChar).Value = dwData["BSFDZ"].ToString();
            or1.Parameters.Add("BSFDZLEIST", OracleType.NVarChar).Value = dwData["BSFDZLEIST"].ToString();
            or1.Parameters.Add("BSKNOTEN", OracleType.NVarChar).Value = dwData["BSKNOTEN"].ToString();
            or1.Parameters.Add("BSFAKTOR", OracleType.NVarChar).Value = dwData["BSFAKTOR"].ToString();
            or1.Parameters.Add("BSSRFNR", OracleType.NVarChar).Value = dwData["BSSRFNR"].ToString();
            or1.Parameters.Add("BSCADKEY", OracleType.NVarChar).Value = dwData["BSCADKEY"].ToString();
            or1.Parameters.Add("BSANZTB", OracleType.NVarChar).Value = dwData["BSANZTB"].ToString();
            or1.Parameters.Add("BSKRANF", OracleType.NVarChar).Value = dwData["BSKRANF"].ToString();
            or1.Parameters.Add("BSKRENDE", OracleType.NVarChar).Value = dwData["BSKRENDE"].ToString();
            or1.Parameters.Add("BSKRMITTE", OracleType.NVarChar).Value = dwData["BSKRMITTE"].ToString();
            or1.Parameters.Add("BSFDFLGKR", OracleType.NVarChar).Value = dwData["BSFDFLGKR"].ToString();
            or1.Parameters.Add("BSKRART", OracleType.NVarChar).Value = dwData["BSKRART"].ToString();
            or1.Parameters.Add("BSSCHAERBR", OracleType.NVarChar).Value = dwData["BSSCHAERBR"].ToString();
            or1.Parameters.Add("BSRIETF", OracleType.NVarChar).Value = dwData["BSRIETF"].ToString();
            or1.Parameters.Add("BSFDFLGRI", OracleType.NVarChar).Value = dwData["BSFDFLGRI"].ToString();
            or1.Parameters.Add("BSBEM", OracleType.NVarChar).Value = dwData["BSBEM"].ToString();
            or1.Parameters.Add("BSZOLLTNR", OracleType.NVarChar).Value = dwData["BSZOLLTNR"].ToString();
            or1.Parameters.Add("BSSUBSTGR", OracleType.NVarChar).Value = dwData["BSSUBSTGR"].ToString();
            or1.Parameters.Add("BSHANDICAP", OracleType.NVarChar).Value = dwData["BSHANDICAP"].ToString();
            or1.Parameters.Add("BSAFFINITY", OracleType.NVarChar).Value = dwData["BSAFFINITY"].ToString();
            or1.Parameters.Add("BSSUBST1", OracleType.NVarChar).Value = dwData["BSSUBST1"].ToString();
            or1.Parameters.Add("BSSUBST2", OracleType.NVarChar).Value = dwData["BSSUBST2"].ToString();
            or1.Parameters.Add("BSBLEACHED", OracleType.NVarChar).Value = dwData["BSBLEACHED"].ToString();
            or1.Parameters.Add("BSCLORINEST", OracleType.NVarChar).Value = dwData["BSCLORINEST"].ToString();
            or1.Parameters.Add("BSFIXTEMP", OracleType.NVarChar).Value = dwData["BSFIXTEMP"].ToString();
            or1.Parameters.Add("BSPRODH", OracleType.NVarChar).Value = dwData["BSPRODH"].ToString();
            or1.Parameters.Add("BSMATKL", OracleType.NVarChar).Value = dwData["BSMATKL"].ToString();
            or1.Parameters.Add("BSPLGRP", OracleType.NVarChar).Value = dwData["BSPLGRP"].ToString();
            or1.Parameters.Add("BSPLANART", OracleType.NVarChar).Value = dwData["BSPLANART"].ToString();
            or1.Parameters.Add("BSEKGRP", OracleType.NVarChar).Value = dwData["BSEKGRP"].ToString();
            or1.Parameters.Add("BSBSTME", OracleType.NVarChar).Value = dwData["BSBSTME"].ToString();
            or1.Parameters.Add("BSVABME", OracleType.NVarChar).Value = dwData["BSVABME"].ToString();
            or1.Parameters.Add("BSEKWSL", OracleType.NVarChar).Value = dwData["BSEKWSL"].ToString();
            or1.Parameters.Add("BSINKZ", OracleType.NVarChar).Value = dwData["BSINKZ"].ToString();
            or1.Parameters.Add("BSINPR", OracleType.NVarChar).Value = dwData["BSINPR"].ToString();
            or1.Parameters.Add("BSBEWAB", OracleType.NVarChar).Value = dwData["BSBEWAB"].ToString();
            or1.Parameters.Add("BSFILLER", OracleType.NVarChar).Value = dwData["BSFILLER"].ToString();
            Connect2Proxy(or1);

        }
        public void UBS02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BSSATZ SET BSMANDANT=:BSMANDANT:,BSKART=:BSKART:,BSAENDZL=:BSAENDZL:,BSAENDBEN=:BSAENDBEN:,BSAENDDAT=:BSAENDDAT:,BSNEUBEN=:BSNEUBEN:,BSNEUDAT=:BSNEUDAT:,BSMTART=:BSMTART:,BSBEZ=:BSBEZ:,BSSTDKVAR=:BSSTDKVAR:,BSSTAKZ=:BSSTAKZ:,BSMUSTER=:BSMUSTER:,BSFARBVW=:BSFARBVW:,BSFARBSTUE=:BSFARBSTUE:,BSPFVARN=:BSPFVARN:,BSPROGRP=:BSPROGRP:,BSARTGRP=:BSARTGRP:,BSPMGRP=:BSPMGRP:,BSBAUMKZ=:BSBAUMKZ:,BSVERWEN=:BSVERWEN:,BSFDZ=:BSFDZ:,BSFDZLEIST=:BSFDZLEIST:,BSKNOTEN=:BSKNOTEN:,BSFAKTOR=:BSFAKTOR:,BSSRFNR=:BSSRFNR:,BSCADKEY=:BSCADKEY:,BSANZTB=:BSANZTB:,BSKRANF=:BSKRANF:,BSKRENDE=:BSKRENDE:,BSKRMITTE=:BSKRMITTE:,BSFDFLGKR=:BSFDFLGKR:,BSKRART=:BSKRART:,BSSCHAERBR=:BSSCHAERBR:,BSRIETF=:BSRIETF:,BSFDFLGRI=:BSFDFLGRI:,BSBEM=:BSBEM:,BSZOLLTNR=:BSZOLLTNR:,BSSUBSTGR=:BSSUBSTGR:,BSHANDICAP=:BSHANDICAP:,BSAFFINITY=:BSAFFINITY:,BSSUBST1=:BSSUBST1:,BSSUBST2=:BSSUBST2:,BSBLEACHED=:BSBLEACHED:,BSCLORINEST=:BSCLORINEST:,BSFIXTEMP=:BSFIXTEMP:,BSPRODH=:BSPRODH:,BSMATKL=:BSMATKL:,BSPLGRP=:BSPLGRP:,BSPLANART=:BSPLANART:,BSEKGRP=:BSEKGRP:,BSBSTME=:BSBSTME:,BSVABME=:BSVABME:,BSEKWSL=:BSEKWSL:,BSINKZ=:BSINKZ:,BSINPR=:BSINPR:,BSBEWAB=:BSBEWAB:,BSFILLER=:BSFILLER:"
                + " WHERE  BSMANDANT=:BSMANDANT: AND BSKART=:BSKART:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public DataSet QueryBSSATZ(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    SResult = QBS00(dwData);
                    break;
                case 1:
                    SResult = QBS01(dwData);
                    break;
                case 2:
                    SResult = QBS02(dwData);
                    break;
                case 3:
                    SResult = QBS03(dwData);
                    break;
                default:
                    break;
            }
            return SResult;
        }
        public DataSet QBS00(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM BSSATZ WHERE  ROWNUM<2 ";
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBS01(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BSSATZ"
                + " WHERE  BSMANDANT=:BSMANDANT: AND BSKART=:BSKART:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBS02(DataRow dwData, int option = 1)
        {
            or1 = OracleDB.CreateCommand();

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT  WF.* FROM WDECK WD "
                + " JOIN WASTKE ON WDMANDANT=WAKMANDANT AND WDART=WAKART AND WDVAR=WAKVAR AND WDFARBE=WAKWCOL"
                + " JOIN BSSATZ WF ON BSMANDANT=WAKMANDANT AND BSKART=WAKKART"
                + " WHERE WDMANDANT=:WDMANDANT: AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS:  AND WDAUFLFD=:WDAUFLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBS03(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT M.* FROM  BSSATZ M JOIN ABPOS ON ABPART=BSKART AND ABPMANDANT=BSMANDANT"
                + " WHERE  ABPMANDANT=:ABPMANDANT: AND ABPAUFKRS=:ABPAUFKRS: AND ABPAUFLFD=:ABPAUFLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
    }
}
